package com.zahb.qadx.ui.adapter;


import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.zahb.qadx.R;
import com.zahb.qadx.model.AssessmentBean;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;


public class AssessmentAdapter extends BaseQuickAdapter<AssessmentBean.ListEntity, BaseViewHolder> implements LoadMoreModule {
    public AssessmentAdapter(int layoutResId, @Nullable List<AssessmentBean.ListEntity> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, AssessmentBean.ListEntity s) {

        baseViewHolder.setText(R.id.tvTime,s.getOpenTime())
                .setText(R.id.tvCompany,TextUtils.isEmpty(s.getExamName())?"":s.getExamName())
                .setText(R.id.tvGrade, getScore(s.getUserScore())+"")
                .setText(R.id.tvStatus,s.getExamResult())
                .setText(R.id.tvType,s.relationshipType==1?"考试任务":"培训班级")
                .setText(R.id.tvCertificate,getStatus(s.certificateStatus));


    }

    public String getScore(double score){
        if(score == (int)score){
            return  ((int)score)+"";
        }else{
            return score+"";
        }
    }


    public String getStatus(int status){

        if(status==1){
            return "无证书";
        }
        if(status==2){
            return "未获得";
        }
        if(status==3){
            return "已获得";
        }
        return "";
    }

}
